package com.example.service;

import com.example.entity.User;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**@Description:@CacheConfig指定缓存的名称
 *
 * @author huxiaot
 * @date 2019年10月15日
 */
@Service

public class TestService {


    @Cacheable(cacheNames = "cache_user", key="'user_' + #id")
    public User getById(long id) {

        System.out.println("进来查库了--------->{}"+ id);

        User user = new User();
        user.setUserId(1);
        user.setUserName("MarkerHub" + id);
        return user;
    }

}

